﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace iss.sg4210.se18.team6s.jass.Reports.Forms
{
    public partial class AdvertResponses : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   


            if (Page.IsPostBack == false)
            {
                AdvertResponsesDataSetTableAdapters.DistinctAdvertisersTableAdapter Ta =
                 new AdvertResponsesDataSetTableAdapters.DistinctAdvertisersTableAdapter();

                AdvertResponsesDataSet.DistinctAdvertisersDataTable dt = new AdvertResponsesDataSet.DistinctAdvertisersDataTable();



                Ta.Fill(dt);
                DropDownList1.DataSource = dt;
                DropDownList1.DataTextField = "UserName";
                DropDownList1.DataValueField = "UserName";
                DropDownList1.DataMember = "DistinctAdvertisers";
                DropDownList1.DataBind();

                ReportViewer1.Visible = false;

            }


        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ReportViewer1.Visible = true;

            AdvertResponsesDataSetTableAdapters.vw_TotalAdvertResponsesTableAdapter Ta =
               new AdvertResponsesDataSetTableAdapters.vw_TotalAdvertResponsesTableAdapter();

            AdvertResponsesDataSet.vw_TotalAdvertResponsesDataTable dt = new AdvertResponsesDataSet.vw_TotalAdvertResponsesDataTable();
         
            Ta.Fill(dt, DropDownList1.SelectedValue);

            System.Data.DataTable TmpDataTable = dt;

            ReportDataSource Rds = new ReportDataSource("AdvertResponsesDataSet", TmpDataTable);
            //ReportViewer1.Reset();
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(Rds);
            String tmpStr = Rds.ToString();

            ReportViewer1.LocalReport.Refresh();
        }
    }
}